<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title> Insha - Css3 Responsive Sidebar Menu</title>

    <link href="static/css/css2.css" rel="stylesheet">
    <link href='static/css/boxicons.min.css' rel='stylesheet'>
    <link rel="stylesheet" href="static/css/insha-style.css">

</head>
<body>

<div class="main" id="app">
    <div class="sidebar">
        <div class="logo_content">
            <div class="logo">
                <div class="logo_name">
                    <a href="#">
                        <i class='bx bxs-bank'></i>
                        银行业务管理系统
                    </a>
                </div>
            </div>
            <i class='bx bx-menu' id="toggle-menu-btn"></i>
        </div>
        <ul class="nav_list">
            <li>
                <a href="online.html">
                    <i class='bx bx-yen'></i>
                    <span class="links_name">网上银行</span>
                </a>
                <span class="tooltip">网上银行</span>
            </li>
            <li>
                <a href="counter.html">
                    <i class='bx bxs-user-account'></i>
                    <span class="links_name">银行柜面</span>
                </a>
                <span class="tooltip">银行柜面</span>
            </li>
        </ul>
    </div>
    <div class="home_content">
        <div class="text">网上银行</div>
        <div class="rg_layout">
            <div class="rg_left">
                <p>用户登录</p>
                <p>LOGIN</p>

            </div>
            <div class="rg_center">
                <div class="rg_form">
                    <!--定义表单 form-->
                    <form action="#" method="">
                        <table id="tbe1">
                            <tr>
                                <td class="td_left"><label for="idCard">身份证号</label></td>
                                <td class="td_right"><input type="text" name="idCard" id="idCard"
                                                            placeholder="请输入身份证号" v-model="idCard" @blur="ic()">
                                </td>

                            </tr>
                            <tr>
                                <td class="td_left"><label for="password">密码</label></td>
                                <td class="td_right"><input type="password" name="password" id="password"
                                                            placeholder="数字加字母大小写加字符不小于8位"
                                                            v-model="password" @blur="pd()"></td>
                            </tr>


                            <tr>
                                <td colspan="2" align="center"><input type="button" id="btn_sub" value="确认登录"
                                                                      @click="cm()"></td>
                            </tr>
                        </table>

                    </form>


                </div>
            </div>
            <div class="rg_right">
                <p>使用手机号+验证码方式登录<a href="online.html">切换登录方式</a></p>
            </div>
        </div>
    </div>
</div>


<script src="static/js/scripts.js"></script>
<script src="static/js/vue.js"></script>
<script src="static/js/axios.min.js"></script>
<script>
    const app = new Vue({
        el: "#app",
        data: {

            password: "",
            idCard: ""

        },
        methods: {

            ic() {
                if (this.idCard != "") {
                    let rule = new RegExp("(^\\d{18}$)")
                    if (rule.test(this.idCard) == false) {
                        alert("您的身份证号格式不正确，请重新输入")
                        this.idCard = "";
                    }
                }
            },
            pd() {

                if (this.password != "") {
                    let rule = new RegExp("(^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,20}$)");
                    if (rule.test(this.password) == false) {
                        alert("您的密码格式不正确，请重新输入")
                        this.password = "";
                    }
                }

            },

            cm() {
                if (this.password == "" || this.idCard == "") {
                    alert("上述信息请勿为空")
                } else {

                    //此处参数待定
                    axios.post("http://localhost:8080/user/login", {
                        type: 1,
                        username: this.idCard,
                        password: this.password
                    }).then(res => {
                        let msg = res.data.message;
                        let code = res.data.code;
                        if (code == 200) {
                            //登录成功跳转页面
                            location.href = "onlineindex.html"
                        } else {
                            alert(msg)
                            alert("如为首次登陆网上银行，请使用手机号+验证码得方式登录")
                        }
                    })
                }
            }


        }
    })
</script>

</body>
</html>
